home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3879 < prev    next >
Encoding:
Text File  |  1996-08-05  |  888 b   |  33 lines

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Unable to check calloc's return values
  5. Date: 31 Jan 1996 13:12:05 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4eobdl$5bj@umbc9.umbc.edu>
  8. References: <4emept$ifv@hpg30a.csc.cuhk.hk>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. CHAN CHUN CHUNG <s910500@acs.csc.cuhk.hk> wrote:
  13. |> Could anyone tell me why the following line is complained by the
  14. |> compiler? 
  15. |> 
  16. |> if ((float **x = (float **) calloc(9, sizeof(float *)))
  17. |>    == 0) exit(1);
  18. |> 
  19. |> What's the right way to check the calloc's return value?
  20.  
  21. The correct way is:
  22.  
  23. #include <stdlib.h>
  24. ...
  25. float **x;
  26. ...
  27. if ((x = calloc (9, sizeof (*x))) == NULL)
  28.    exit (1);
  29. -- 
  30. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  31.  
  32. Jonas J. Schlein  (schlein@gl.umbc.edu)
  33.